package com.example.demo.service.impl;

import com.example.demo.entity.basicquery;
import com.example.demo.entity.deletebasic;
import com.example.demo.entity.fnameview;
import com.example.demo.mapper.querymanageMapper;
import com.example.demo.service.QuerymanageService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.*;

@Service
public class QuerymanageServiceImpl implements QuerymanageService {
    @Resource
    private querymanageMapper querymanageMapper;
    @Override
    public List fnameview(@RequestBody fnameview fnameview)//根据故障名称查询障停机时间、维修时间、发电量损失
    {

        return querymanageMapper.selectFname(fnameview);}

    @Override
    public List basicquery(@RequestBody deletebasic deletebasic)//根据机组编号查询机组发电量、全场发电量,查询设备的运行状况,备件消耗等情况
    {
        basicquery basicquery1=querymanageMapper.basicquery(deletebasic);//查询机组是否存在
        if (basicquery1!=null)
        {
            int parts=querymanageMapper.partsquery(deletebasic);//查询设备消耗备件数量
            basicquery1.setParts(parts);
            List<basicquery> b =new LinkedList<>();
            b.add(basicquery1);
            return b;
        }
        else return null;
    }
    @Override
    public List faultnumquery()
    {
        return querymanageMapper.faultnumquery();//故障统计
    }
}
